<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--    <button type="button" onclick="myBtn()">按钮</button>-->
<!--    <script type="text/javascript">-->

<!--        function myBtn(){-->
<!--            alert("hello world");-->
<!--        }-->

<!--    </script>-->


    <button type="button" id="btn">按钮</button>
    <script>
        function func(){
            alert("hello world!");
        }
        // document.getElementById("btn").onclick = func;
        var a = document.getElementById("btn");
        a.onclick = func;
    </script>

</body>
</html>